package net.lgpage.fragment;

import java.io.Serializable;

import net.lgpage.tool.Dispatcher;
import net.lgpage.tool.ImageTool;
import net.lgpage.tool.SharedPreferencesTool;
import net.lgpage.tool.TagTool;
import net.lgpage.util.PromptTool.ToastUtil;
import android.support.v4.app.Fragment;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;

public class BaseFragment extends Fragment{
	
	public String Tag = getClass().getSimpleName();

	public void loadImage(String url,ImageView iv){
		ImageTool.loadImage(url, iv);
	}
	public void loadImage(String url,ImageView iv,DisplayImageOptions option){
		ImageTool.loadImageUseOption(url, iv,option);
	}
	
	/*public void loadCircleImage(String url,ImageView iv){
		ImageTool.loadCircleImage(url, iv);
	}*/
	
	public Object load(String key,Object defValue){
		return new SharedPreferencesTool(getActivity()).load( key, defValue);
	}
	public Object userLoad(String key,Object defValue){
		return new SharedPreferencesTool(getActivity()).userLoad( key, defValue);
	}
	public Object load(String name,String key,Object defValue){
		return new SharedPreferencesTool(getActivity()).load( name, key, defValue);
	}
	public void putUserValue(String key, Object value){
		new SharedPreferencesTool(getActivity()).putUserValue( key, value);
	}
	public void putAppValue(String key, Object value){
		new SharedPreferencesTool(getActivity()).putAppValue( key, value);
	}
	public void putValue(String name,String key, Object value) {
		new SharedPreferencesTool(getActivity()).putValue(name, key, value);
	}
	
	public float getDensity(){
		return getResources().getDisplayMetrics().density;
	}
	public String intentGetObj() {
		return new Dispatcher(this).intentGetObj();
	}
	public Object intentGetObj(Object defVal) {
		return new Dispatcher(this).intentGetObj(defVal);
	}
	public Object intentGetObj(String key,Object defVal) {
		return new Dispatcher(this).intentGetObj(key,defVal);
	}

	public void toActivity(Class clazz, Object obj) {
		new Dispatcher(this).toActivity(clazz, obj);
	}

	public void toActivity(Class clazz) {
		new Dispatcher(this).toActivity(clazz);
	}

	public void toActivityForResult(Class clazz, int requestCode) {
		new Dispatcher(this).toActivityForResult(clazz, requestCode);
	}

	public void toActivityForResult(Class clazz, Object obj, int requestCode) {
		new Dispatcher(this).toActivityForResult(clazz, obj, requestCode);
	}
	
	public void toast(String str){
		ToastUtil.noretryToast(getActivity(), str);
	}
	
	public void tag(String msg){
		TagTool.v(Tag, msg);
	}
	
	public void onRefesh(Object ...objs){
		
	}
}
